package com.ml.mall.service.log.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ml.mall.bean.page.Page;
import com.ml.mall.bean.req.log.OperationLogQueryDto;
import com.ml.mall.bean.res.log.OperationLogQueryRes;
import com.ml.mall.entity.log.OperationLog;
import com.ml.mall.mapper.log.OperationLogMapper;
import com.ml.mall.mapper.sys.SysUserMapper;
import com.ml.mall.service.log.OperationLogService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author kyyang
 * Created 2021-01-07
 */
@Service
public class OperationLogServiceImpl extends ServiceImpl<OperationLogMapper, OperationLog> implements OperationLogService {

    @Autowired
    private OperationLogMapper operationLogMapper;

    @Autowired
    private SysUserMapper sysUserMapper;

    @Override
    public Page<OperationLogQueryRes> operationLogQuery(OperationLogQueryDto operationLogQueryDto) {
        Page<OperationLogQueryRes> page = new Page<>(operationLogQueryDto.getPageIndex(), operationLogQueryDto.getPageNum());
        Integer count = operationLogMapper.selectCount(operationLogQueryDto);
        page.setTotal(count);
        if(count > 0){
            List<OperationLogQueryRes> records = operationLogMapper.selectPage(operationLogQueryDto);
            page.setRecords(records);
        }
        return page;
    }
}
